<?php 
$v_filter = "";
if(isset($_REQUEST['hdn_filter'])){
	$v_filter=_replace_bad_char(trim($_REQUEST['hdn_filter']));
}	
$v_listtype_id = intval($_REQUEST['hdn_listtype_id']);
$v_code = _restore_XML_bad_char($_REQUEST['txt_code']);
$v_name = _restore_XML_bad_char($_REQUEST['txt_name']);
$v_order = intval($_REQUEST['txt_order']);
if ($v_order==""){
	$v_order = NULL;
}
$v_status = $_REQUEST['hdn_listtype_status'];
$v_have_file = $_REQUEST['hdn_listtype_have_file'];
$v_save_and_add_new = intval($_REQUEST['hdn_save_and_add_new']);
$v_url = "/list/listtype/index.php?modal_dialog_mode=1" . "&hdn_listtype_id=" . $v_listtype_id . "&fuseaction=DISPLAY_SINGLE_LISTTYPE" ;
// Kiem tra xem nguoi dang nhap hien thoi co quyen cap nhat hay khong?
if(!_check_permission_on_function($_SESSION['staff_id'], $_ISA_APP_CODE, _CONST_ONEGATE_LISTTYPE_UPDATE)){?>
	<script>
		alert("<? echo _CONST_FUNCTION_PERMISSION_ERROR; ?>");
		if (_MODAL_DIALOG_MODE==1){
			window.location = "<? echo $v_url; ?>";
		}else{
			window.history.back();
		}	
	</script><?
}
//CSDL SQL
if(_is_sqlserver()){
	$cmd = @mssql_init("ONEGATE_ListtypeUpdate",$conn);	
	@mssql_bind($cmd,"@p_listtype_id",$v_listtype_id,SQLINT4);
	@mssql_bind($cmd,"@p_code",$v_code,SQLVARCHAR);
	@mssql_bind($cmd,"@p_name",$v_name,SQLVARCHAR);
	if (is_null($v_order)){
		@mssql_bind($cmd,"@p_order",$v_order,SQLINT2, false, true, 2);
	}else{	
		@mssql_bind($cmd,"@p_order",$v_order,SQLINT2);
	}
	@mssql_bind($cmd,"@p_have_file",$v_have_file,SQLINT1);	
	@mssql_bind($cmd,"@p_status",$v_status,SQLINT1);
	$result = @mssql_execute($cmd);
	$rs = @mssql_fetch_array($result);
	$v_error = _replace_bad_char(trim($rs['RET_ERROR']));
	@mssql_free_result($result);
}

if (!is_null($v_error) and $v_error<>""){?>
	<script>
		alert("<?php echo $v_error; ?>");
		if (_MODAL_DIALOG_MODE==1){
			window.location = "<?php echo $v_url; ?>";
		}else{
			window.history.back();
		}	
	</script><?php
	exit;
}
sleep(0);
?>
<form action="index.php" method="post" name="f_back">
	<input type="hidden" name="fuseaction" value="DISPLAY_ALL_LISTTYPE">
	<input name="hdn_filter" type="hidden" value="<?php echo $v_filter; ?>">
	<input type="hidden" name="hdn_item_id" value="<?php echo $v_listtype_id;?>">
</form>
<Script language="javascript">
	if ("<?php echo $v_save_and_add_new; ?>" != "1")
		return_value = "<?php echo $v_listtype_id; ?>" + _LIST_DELIMITOR + "<?php echo $v_code; ?>"  + _LIST_DELIMITOR + "<?php echo $v_name; ?>" 
	else
		return_value = "";
	goto_after_update_data(<?php echo $v_save_and_add_new; ?>, "DISPLAY_SINGLE_LISTTYPE",return_value);
</Script>
